import type { App } from 'vue';
import { createRouter, createWebHistory } from "vue-router";
import { setupLayouts } from 'virtual:generated-layouts'
import generatedRoutes from '~pages'
import router from 'virtual:generated-pages'
const routes = setupLayouts(generatedRoutes)



// app router
export const routerMaker = () => createRouter({
  history: createWebHistory(),
  routes,
  strict: true,
  scrollBehavior: () => ({ left: 0, top: 0 }),
});


// config router
export function setupRouter(app: App<Element>) {
  const router = routerMaker()
 
  app.use(router);
  return router
}


routerMaker.beforeEach = ((to: any,from: any,next: any) => {
  console.log(to,from,next);
  
})